home *** CD-ROM | disk | FTP | other *** search
- /***********************************************************************
- * This is an example that shows how to open a p96 Screen and a Window
- * to get input events and how to paint on that screen.
- * Program terminates when space bar or any mouse button is pressed!
- *
- * alex (Sun Dec 29 01:42:59 1996)
- *
- * converted by Martin <MarK> Kuchinka, 14.8.2002
- ***********************************************************************/
-
- MODULE 'libraries/picasso96',
- 'picasso96'
-
- MODULE 'intuition/intuition',
- 'utility/tagitem',
- 'graphics/modeid'
-
- DEF P96Base
-
- DEF WindowTags=[
- WA_Width, 200,
- WA_Height, 300,
- WA_MinWidth, 100,
- WA_MinHeight, 100,
- WA_MaxWidth, -1,
- WA_MaxHeight, -1,
- WA_SimpleRefresh,TRUE,
- WA_RMBTrap, TRUE,
- WA_Activate, TRUE,
- WA_CloseGadget, TRUE,
- WA_DepthGadget, TRUE,
- WA_DragBar, TRUE,
- WA_SizeGadget, TRUE,
- WA_SizeBBottom, TRUE,
- WA_GimmeZeroZero,TRUE,
- WA_ScreenTitle, 'Picasso96 API Test',
- WA_IDCMP, IDCMP_RAWKEY|IDCMP_CLOSEWINDOW,
- TAG_END]:TagItem
-
- PROC main()
- IF P96Base:=OpenLibrary(P96NAME,2)
- DEF rda
- DEF sc:PTR TO Screen
- DEFL Width=640,Height=480,Depth=8,DisplayID
- DEF array=[0,0,0]
-
- IF rda:=ReadArgs('Width=W/N,Height=H/N,Depth=D/N', array, NIL)
- IF array[0] THEN Width :=Long(array[0])
- IF array[1] THEN Height:=Long(array[1])
- IF array[2] THEN Depth :=Long(array[2])
- FreeArgs(rda)
- ENDIF
-
- IF (DisplayID:=p96BestModeIDTags(
- P96BIDTAG_NominalWidth, Width,
- P96BIDTAG_NominalHeight,Height,
- P96BIDTAG_Depth, Depth,
- P96MA_FormatsAllowed, RGBFF_CLUT|RGBFF_R5G6B5|RGBFF_R8G8B8|RGBFF_A8R8G8B8,
- TAG_DONE))=INVALID_ID
- DisplayID:=p96RequestModeIDTags(
- P96MA_MinWidth, Width,
- P96MA_MinHeight, Height,
- P96MA_MinDepth, Depth,
- P96MA_WindowTitle, 'RequestModeID Test',
- P96MA_FormatsAllowed, RGBFF_CLUT|RGBFF_R5G6B5|RGBFF_R8G8B8|RGBFF_A8R8G8B8,
- TAG_DONE)
- ENDIF
-
- IF sc:=p96OpenScreenTags(
- P96SA_Width, Width,
- P96SA_Height, Height,
- P96SA_Depth, Depth,
- P96SA_Pens, [-1]:W,
- P96SA_Title, 'Picasso96 API Test',
- P96SA_DisplayID, DisplayID,
- TAG_DONE)
-
- DEF wdf:PTR TO Window, wdp:PTR TO Window
- DEF Dimensions[4]:W
-
- Dimensions[0] := 0
- Dimensions[1] := sc.BarHeight+1
- Dimensions[2] := sc.Width
- Dimensions[3] := sc.Height-sc.BarHeight-1
-
- wdp := OpenWindowTags(NIL,
- WA_CustomScreen,sc,
- WA_Title, 'WritePixel',
- WA_Left, (sc.Width/2-200)/2 + sc.Width/2,
- WA_Top, (sc.Height-sc.BarHeight-300)/2,
- WA_Zoom, Dimensions,
- TAG_MORE, WindowTags)
-
- wdf := OpenWindowTags(NIL,
- WA_CustomScreen,sc,
- WA_Title, 'FillRect',
- WA_Left, (sc.Width/2-200)/2,
- WA_Top, (sc.Height-sc.BarHeight-300)/2,
- WA_Zoom, Dimensions,
- TAG_MORE, WindowTags)
-
- IF wdf && wdp
- DEF rpf=wdf.RPort:PTR TO RastPort
- DEF rpp=wdp.RPort:PTR TO RastPort
- DEF terminate=FALSE:BOOL
- DEFUL signals=(1<<wdf.UserPort.SigBit)|(1<<wdp.UserPort.SigBit)
- DEFUL format=p96GetBitMapAttr(sc.RastPort.BitMap, P96BMA_RGBFORMAT)
-
- Rnd((wdf+wdp)&$8000.0000) // just to get a negative number
-
- REPEAT
- DEFW x1, y1, x2, y2, x3, y3
-
- x1 := Rnd(wdf.Width)
- y1 := Rnd(wdf.Height)
- x2 := Rnd(wdf.Width)
- y2 := Rnd(wdf.Height)
- x3 := Rnd(wdp.Width)
- y3 := Rnd(wdp.Height)
-
- IF format=RGBFB_CLUT
- SetAPen(rpf, Rnd(256))
- RectFill(rpf, Min(x1,x2), Min(y1,y2), Max(x1,x2), Max(y1,y2))
-
- SetAPen(rpp,Rnd(256))
- WritePixel(rpp, x3, y3)
- ELSE
- p96RectFill(rpf, Min(x1,x2), Min(y1,y2), Max(x1,x2), Max(y1,y2),
- ((Rnd(256))<<16)|((Rnd(256))<<8)|(Rnd(256)))
- p96WritePixel(rpp, x3, y3,
- ((Rnd(256))<<16)|((Rnd(256))<<8)|(Rnd(256)))
- ENDIF
- IF SetSignal(0, signals) & signals
- DEF imsg:PTR TO IntuiMessage
-
- WHILE imsg:=GetMsg(wdf.UserPort)
- ELSEWHILE imsg:=GetMsg(wdp.UserPort)
- ALWAYS
- IF imsg.Class=IDCMP_CLOSEWINDOW||
- (imsg.Class=IDCMP_RAWKEY&&(imsg.Code=$40||imsg.Code=$45))
- // Close window, press SPACE bar or ESCAPE key to end program
- terminate:=TRUE
- ENDIF
- ReplyMsg(imsg)
- ENDWHILE
- ENDIF
- UNTIL terminate
-
- Forbid()
- DEF msg
- WHILE msg:=GetMsg(wdf.UserPort) DO ReplyMsg(msg)
- WHILE msg:=GetMsg(wdp.UserPort) DO ReplyMsg(msg)
- Permit()
- ELSE PrintF('Can''t open window!\n')
-
- IF wdf THEN CloseWindow(wdf)
- IF wdp THEN CloseWindow(wdp)
-
- p96CloseScreen(sc)
- ELSE PrintF('Can''t open screen: \dx\dx\d \h\n',Width,Height,Depth,DisplayID)
- CloseLibrary(P96Base)
- ELSE PrintF('Can''t open picasso96api.library v2+\n')
- ENDPROC
-